import BaseController from '@ctsy/controller/dist/base_controller'
import socks from '../tcp';
import { WSRPCServer } from '@ctsy/ws-rpc-server';

export default class Tcp extends BaseController{
    async send({Data}){
        console.log('send',Data);
        for(let x of Object.values(socks)){
            x.write(Data);
        }
    }
    async gsend(){
        if(this._ctx.query&&this._ctx.query.x){  
            for(let x of Object.values(socks)){
                // x.write(this._ctx.query.f+' 说 '+this._ctx.query.x);
                x.write(this._ctx.query.f+','+this._ctx.query.x)
            }
            //网页全局推送
            WSRPCServer.publish('l',{x:this._ctx.query.x,f:this._ctx.query.f})
        }
        return this._ctx.query;
    }
}